package com.qqt.csr.ixport.task;

import jakarta.annotation.PostConstruct;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author: yang hao
 * @Date: 2025/2/6 15:26
 * @Description: 任务调度器
 **/
// @Component
@Deprecated
public class TaskScheduler {

    private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
    private final TaskManager taskManager;

    /**
     * 构造方法
     *
     * @param taskManager 任务管理器
     */
    public TaskScheduler(TaskManager taskManager) {
        this.taskManager = taskManager;
    }

    /**
     * 启动任务调度器
     */
    @PostConstruct
    public void start() {
        scheduler.scheduleAtFixedRate(
                () -> taskManager.startProcessing(100),
                0, 10, TimeUnit.SECONDS
        );
    }

}
